<template>
  <div class="food-item">
    <div class="image" @click="$emit('click', food, 'image')">
      <img :src="food.image" width="70" />
    </div>
    <dl class="info" @click="$emit('click', food, 'info')">
      <dt>{{food.name}}</dt>
      <dd class="sales">{{food.sales}}</dd>
      <dd class="price"><i>&yen;</i>{{food.price}}</dd>
    </dl>
    <div class="buy">
      <button-buy v-model="food.count"></button-buy>
    </div>
  </div>
</template>

<script>
import ButtonBuy from 'components/common/ButtonBuy'
import Count from 'components/common/Count'

export default {
  name: 'FoodItem',

  components: {
    ButtonBuy,
    Count
  },

  props: {
    food: {
      type: Object,
      default() {
        return {
          id: 0,
          name: 'FOOD NAME',
          image: '',
          price: '0.00',
          sales: 0,
          count: 0
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
.food-item {
  position: relative;
  display: flex;
  padding: 15px 0;
  border-bottom: 1px solid #f3f5f7;

  .image {
    flex: 0 0 70px;
    margin-right: 10px;
  }

  .info {
    position: relative;
    flex: 1;
    margin: 0;

    dt {
      display: -webkit-box;
      -webkit-line-clamp: 16px;
      -webkit-box-orient: vertical;
      text-overflow: ellipsis;
      word-break: break-all;
      overflow: hidden;
      max-height: 30px;

      margin: 0 0 5px 0;
      font-size: 14px;
      line-height: 15px;
      color: rgb(7, 17, 27);
    }

    dd {
      margin: 0;
      font-size: 12px;
      line-height: 1.25em;
      color: rgb(147, 153, 159);
    }

    .price {
      font-size: 16px;
      color: #ff3366;

      i {
        font-style: normal;
        font-size: 0.5em;
      }
    }
  }

  .buy {
    position: absolute;
    right: 0;
    bottom: 0;
  }
}

</style>
